package cn.bigcontainer.alt.meta.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

/**
 * @author cailei
 * @date 2017年6月8日
 */
@Mapper
public interface MDao {

	/**
	 * 获取表table主键pk的最大值
	 * 
	 * @param table
	 * @param pk
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getMaxColumn")
	public Object queryMax(String table, String pk);

	/**
	 * 获取表table的列col中，除前缀prefix之外的字符
	 * @param tcp
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getMax")
	public String queryMaxAfterPrefix(String tcp);

	/**
	 * 
	 * @param sql
	 * @return
	 */
	@DeleteProvider(type = MDaoProvider.class, method = "getSql")
	public int delete(String sql);

	/**
	 * 
	 * @param sql
	 * @return
	 */
	@UpdateProvider(type = MDaoProvider.class, method = "getSql")
	public int update(String sql);

	/**
	 * 
	 * @param sql
	 * @return
	 */
	@InsertProvider(type = MDaoProvider.class, method = "getSql")
	public int insert(String sql);

	/**
	 * 自定义sql查询多条记录
	 * 
	 * @param sql
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getSql")
	public List<Map<String, Object>> queryList(String sql);

	/**
	 * 自定义sql查询多条记录
	 * 
	 * @param sql
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getSqlPaging")
	public List<Map<String, Object>> queryPagingList(String sql, int start, int size);

	/**
	 * 自定义sql查询数据单条记录
	 * 
	 * @param sql
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getSql")
	public Map<String, Object> queryOne(String sql);

	/**
	 * 自定义sql查询数据单条记录
	 * 
	 * @param sql
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getSql")
	public String queryString(String sql);

	/**
	 * 自定义sql查询数据单条记录
	 * 
	 * @param sql
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getSql")
	public Integer queryInteger(String sql);

	/**
	 * 获取sql的记录数
	 * 
	 * @param sql
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getCount")
	public Integer queryCount(String sql);

	/**
	 * @param table
	 * @param where
	 * @return
	 */
	@SelectProvider(type = MDaoProvider.class, method = "getCountBy")
	public Integer queryCountBy(String table, String where);

}
